class Admin::PropertiesController < Admin::AdminController
  layout 'admin'

  def index
    @properties = Property.find(:all)
  end

  def show
    @property = Property.find(params[:id])
  end

  def new
    @property = Property.new
  end

  def edit
    @property = Property.find(params[:id])
  end

  def create
    @property = Property.new(params[:property])

    if @property.save
      flash[:notice] = 'Property was successfully created.'
      redirect_to [:admin, @property]
    else
      render :action => "new"
    end
  end

  def update
    @property = Property.find(params[:id])

    if @property.update_attributes(params[:property])
      flash[:notice] = 'Property was successfully updated.'
      redirect_to [:admin, @property]
    else
      render :action => "edit"
    end
  end

  def destroy
    @property = Property.find(params[:id])
    @property.destroy
    redirect_to admin_properties_url
  end
end
